/**
 * 常量定义
 * 统一管理项目中的常量
 */

// 应用信息
export const APP_INFO = {
  name: 'Convallaria',
  version: '1.0.0',
  description: '企业级前端框架',
  author: 'Convallaria Team'
} as const

// 存储键名
export const STORAGE_KEYS = {
  TOKEN: 'convallaria-token',
  USER_INFO: 'convallaria-user-info',
  SETTINGS: 'convallaria-settings',
  THEME: 'convallaria-theme',
  LANGUAGE: 'convallaria-language'
} as const

// API 相关常量
export const API_CONFIG = {
  TIMEOUT: 10000,
  RETRY_COUNT: 3,
  RETRY_DELAY: 1000
} as const

// 分页相关常量
export const PAGINATION = {
  DEFAULT_PAGE_SIZE: 10,
  PAGE_SIZE_OPTIONS: [10, 20, 50, 100],
  MAX_PAGE_SIZE: 1000
} as const

// 主题相关常量
export const THEME = {
  LIGHT: 'light',
  DARK: 'dark',
  AUTO: 'auto'
} as const

// 语言相关常量
export const LANGUAGE = {
  ZH_CN: 'zh-cn',
  EN_US: 'en-us'
} as const

// 权限相关常量
export const PERMISSIONS = {
  // 系统管理权限
  SYSTEM_USER_LIST: 'system:user:list',
  SYSTEM_USER_CREATE: 'system:user:create',
  SYSTEM_USER_UPDATE: 'system:user:update',
  SYSTEM_USER_DELETE: 'system:user:delete',
  
  SYSTEM_ROLE_LIST: 'system:role:list',
  SYSTEM_ROLE_CREATE: 'system:role:create',
  SYSTEM_ROLE_UPDATE: 'system:role:update',
  SYSTEM_ROLE_DELETE: 'system:role:delete',
  
  SYSTEM_MENU_LIST: 'system:menu:list',
  SYSTEM_MENU_CREATE: 'system:menu:create',
  SYSTEM_MENU_UPDATE: 'system:menu:update',
  SYSTEM_MENU_DELETE: 'system:menu:delete',
  
  SYSTEM_DEPT_LIST: 'system:dept:list',
  SYSTEM_DEPT_CREATE: 'system:dept:create',
  SYSTEM_DEPT_UPDATE: 'system:dept:update',
  SYSTEM_DEPT_DELETE: 'system:dept:delete',
  
  // 监控权限
  MONITOR_ONLINE_LIST: 'monitor:online:list',
  MONITOR_LOGINLOG_LIST: 'monitor:loginlog:list',
  MONITOR_OPERLOG_LIST: 'monitor:operlog:list'
} as const

// 路由相关常量
export const ROUTES = {
  LOGIN: '/login',
  DASHBOARD: '/dashboard',
  PROFILE: '/profile',
  SYSTEM: '/system',
  MONITOR: '/monitor',
  NOT_FOUND: '/404'
} as const

// 状态码常量
export const HTTP_STATUS = {
  SUCCESS: 200,
  CREATED: 201,
  BAD_REQUEST: 400,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  INTERNAL_SERVER_ERROR: 500
} as const

// 正则表达式常量
export const REGEX = {
  EMAIL: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
  PHONE: /^1[3-9]\d{9}$/,
  PASSWORD: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d@$!%*?&]{8,}$/,
  USERNAME: /^[a-zA-Z0-9_]{3,20}$/
} as const

// 文件上传相关常量
export const UPLOAD = {
  MAX_SIZE: 10 * 1024 * 1024, // 10MB
  ALLOWED_TYPES: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf'],
  ALLOWED_EXTENSIONS: ['.jpg', '.jpeg', '.png', '.gif', '.pdf']
} as const

// 缓存相关常量
export const CACHE = {
  USER_INFO_TTL: 30 * 60 * 1000, // 30分钟
  MENU_LIST_TTL: 60 * 60 * 1000, // 1小时
  SETTINGS_TTL: 24 * 60 * 60 * 1000 // 24小时
} as const

// 性能监控相关常量
export const PERFORMANCE = {
  FCP_THRESHOLD: 1800, // First Contentful Paint 阈值
  LCP_THRESHOLD: 2500, // Largest Contentful Paint 阈值
  FID_THRESHOLD: 100,  // First Input Delay 阈值
  CLS_THRESHOLD: 0.1   // Cumulative Layout Shift 阈值
} as const

// API 端点常量
export const API_ENDPOINTS = {
  // 用户相关
  USERS: '/api/users',
  USER_DETAIL: (id: string) => `/api/users/${id}`,
  
  // 角色相关
  ROLES: '/api/roles',
  ROLE_DETAIL: (id: string) => `/api/roles/${id}`,
  
  // 菜单相关
  MENUS: '/api/menus',
  MENU_DETAIL: (id: string) => `/api/menus/${id}`,
  
  // 部门相关
  DEPTS: '/api/depts',
  DEPT_DETAIL: (id: string) => `/api/depts/${id}`,
  
  // 监控相关
  ONLINE_USERS: '/api/monitor/online',
  LOGIN_LOGS: '/api/monitor/loginlog',
  OPER_LOGS: '/api/monitor/operlog',
  
  // 设置相关
  SETTINGS: '/api/settings',
  SETTINGS_EXPORT: '/api/settings/export',
  SETTINGS_IMPORT: '/api/settings/import'
} as const
